-- // Me having no ideas so I decide to practice OOP by making a chat script, by JustSpangebab local Dialogue = {} Dialogue.__index = Dialogue function Dialogue.new(plr) local chr = plr.Character if plr:IsA("Player") and chr ~= nil and chr:FindFirstChildOfClass("Humanoid"):GetState() ~= Enum.HumanoidStateType.Dead then local self = setmetatable({}, {__index = Dialogue}) self.bbg = nil self.sounds = {} if chr.HumanoidRootPart:FindFirstChild("chatThing") then self.bbg = chr.HumanoidRootPart:FindFirstChild("chatThing") else self.bbg = Instance.new("BillboardGui") self.bbg.Name = "chatThing" self.bbg.Size = UDim2.new(8, 0, 3.5, 0) self.bbg.StudsOffsetWorldSpace = Vector3.new(0, 5, 0) self.bbg.Adornee = chr.HumanoidRootPart self.bbg.Parent = chr.HumanoidRootPart for i = 1, 6 do local sound = Instance.new("Sound") sound.Volume = 2 sound.SoundId = "rbxassetid://5855422149" sound.Parent = chr.HumanoidRootPart table.insert(self.sounds, sound) end end return self end end function Dialogue:Chat(tecks) if self.bbg and self.bbg.Parent.Parent:FindFirstChildOfClass("Humanoid"):GetState() ~= Enum.HumanoidStateType.Dead then if tecks:sub(1, 8) == "/e dance" or tecks == "/e cheer" or tecks == "/e laugh" or tecks == "/e point" or tecks == "/e cheer" then return; end if tecks:sub(1, 3) == "/e " then tecks = tecks:sub(4); end if self.bbg:FindFirstChild("ChatBox") then self.bbg:FindFirstChild("ChatBox"):Destroy(); end local img = Instance.new("ImageLabel") img.Size = UDim2.new(1, 0, 1, 0) img.Position = UDim2.new(0, 0, 1, 0) img.BackgroundTransparency = 1 img.Image = "rbxassetid://3635815161" img.Name = "ChatBox" img.Parent = self.bbg local txt = Instance.new("TextBox") txt.Size = UDim2.new(0.8, 0, 0.4, 0) txt.Position = UDim2.new(0.1, 0, 0.35, 0) txt.BackgroundTransparency = 1 txt.TextScaled = true txt.TextEditable = false txt.TextXAlignment = Enum.TextXAlignment.Left txt.TextYAlignment = Enum.TextYAlignment.Top txt.TextColor3 = Color3.new(1, 1, 1) txt.Font = Enum.Font.JosefinSans txt.Parent = img local nameTxt = Instance.new("TextBox") nameTxt.Size = UDim2.new(0.4, 0, 0.25, 0) nameTxt.Position = UDim2.new(0.12, 0, 0.06, 0) nameTxt.BackgroundTransparency = 1 nameTxt.TextScaled = true nameTxt.TextColor3 = Color3.new(1, 1, 1) nameTxt.Font = Enum.Font.JosefinSans nameTxt.Text = owner.Name nameTxt.Parent = img img.ImageTransparency, txt.TextTransparency = 1, 1 game:GetService("TweenService"):Create(img, TweenInfo.new(0.5, Enum.EasingStyle.Back), { Position = UDim2.new() }):Play() game:GetService("TweenService"):Create(img, TweenInfo.new(0.5), {ImageTransparency = 0}):Play() game:GetService("TweenService"):Create(txt, TweenInfo.new(0.5), {TextTransparency = 0}):Play() game:GetService("TweenService"):Create(nameTxt, TweenInfo.new(0.5), {TextTransparency = 0, TextStrokeTransparency = 0}):Play() wait(0.25) for i = 1, tecks:len() do local randSound = self.sounds[math.random(1, #self.sounds)] if randSound then randSound.Pitch = ({0.95, 1, 1.05})[math.random(1, 3)] randSound:Play() end txt.Text = string.sub(tecks, 1, i) if tecks:sub(i, i) == "." then wait(0.3) elseif tecks:sub(i, i) == "-" then wait(0.6) elseif tecks:sub(i, i) == "," then wait(0.15) else wait(0.01) end end delay(30, function() game:GetService("TweenService"):Create(img, TweenInfo.new(0.25, Enum.EasingStyle.Circular), {ImageTransparency = 1, Position = UDim2.new(0, 0, 1, 0)}):Play() game:GetService("TweenService"):Create(txt, TweenInfo.new(0.25, Enum.EasingStyle.Circular), {TextTransparency = 1}):Play() game:GetService("TweenService"):Create(nameTxt, TweenInfo.new(0.25, Enum.EasingStyle.Circular), {TextTransparency = 1, TextStrokeTransparency = 1}):Play() end) end end -- local bbg = Dialogue.new(owner) owner.Chatted:Connect(function(msg) bbg:Chat(msg) end)